<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>指派用户</title>
<jsp:include page="/common.jsp" />
<script type="text/javascript">
	function doAssign(){
		var id=$("#lister").jqGrid('getGridParam','selarrrow');
		id=id.toString();
		if (id===""||id.split(",").length==0) {
			$.messager.alert('警告','请选择一条记录！','warning');
			return;
		}
		var wareid=$("#ware_id").val();
		if(!wareid ||wareid==""){
			$.messager.alert('警告','请先选定仓库！','warning');
			return;
		}
		var url = "${pageContext.request.contextPath}/system/ware/assign.htm?beanIds="
			+ id
			+ "&bean.id="
			+ wareid
			+ "&tmp="+new Date();
		
		$.get(
					url,
					function(response) {
						rst = response;
						switch (rst) {
						case '0':
							//$.messager.alert("提示","指派失败!","info");
							$.messager.show({title:'提示',msg:'指派失败!',timeout:'0'});
							break;
						case '1':
							$.messager.show({title:'提示',msg:'指派成功!',timeout:'10'});
							//$.messager.alert("提示","指派成功!","info");
							break;
						}

					});
	}
</script>
</head>

<body>
	<table cellpadding="0" cellspacing="0" width="100%" height="100%">
		<tbody>
			<tr>
				<td>
					<div class="toolbar" style="background-color: #e0e0e0;">
					   <a plain="true" href="javascript:void(0);"
							class="easyui-linkbutton" iconCls="icon-ok" onclick="doAssign();">确定</a>
					</div>
					<input type="hidden" id="ware_id" value="${ formBean.bean.id}">
				</td>
			</tr>
			
			<tr>
				<td height="100%" valign="top" width="100%">
					<table id="lister" name="lister" style="width:100%;height:100%"></table>
					<div id="pager"></div>
				</td>
			</tr>
		</tbody>
	</table>
	<div id='win' class='easyui-window' title='New Window' style='width:400px;height:300px;padding:5px;' closed='true'>
	</div>
	<script>
	 $(document).ready(function(){
    	 $("#lister")
			.jqGrid(
					{
						url : "${pageContext.request.contextPath }/system/user/listBy.htm",
						datatype : "json",
						colNames : [ '编号','用户名称','用户密码','手机号码','用户地址'],
						colModel : [ 
									{name : 'id',index : 'user_id',searchtype:"number"}, 
									{name : 'userName',index : 'user_name'},
									{name : 'userPassword',index : 'user_password',hidden:true},
									{name : 'userPhone',index : 'user_phone'},
									{name : 'userAddress',index : 'user_address'}
									],
						rowNum : 10,
						shrinkToFit: true,
						rowList : [ 10, 20, 30 ],
						pager : '#pager',
						sortname : 'user_id',
						viewrecords : true,
						sortorder : "asc",
						caption : "用户列表",
						mtype: "POST",
						multiselect: true,
						autowidth:true
					});
		$("#lister").jqGrid('navGrid','#pager', {edit : false,add : false,del : false});
      });
	</script>
</body>
</html>